home *** CD-ROM | disk | FTP | other *** search
- Path: amaryllisp1.appsig.com!user
- From: larry_kearney@appsig.com (Lawrence Kearney)
- Newsgroups: comp.lang.c
- Subject: Re: Interesting declaration???
- Date: Wed, 24 Jan 1996 07:40:14 -0700
- Organization: Applied Signal Technology
- Message-ID: <larry_kearney-2401960740140001@amaryllisp1.appsig.com>
- References: <4e3on1$iir@masala.cc.uh.edu>
- NNTP-Posting-Host: amaryllisp1.appsig.com
-
- > Hi there,
- > I was going through some of the header files of Motif and found an
- > interesting declaration like this:
- >
- > typedef enum{
- > NONE,
- > ONE,
- > TWO} TabelType;
- >
- > #define TableType unsigned char
- > I haven't seen this kind of declartion before and I tried it after seeing this
- > and it worked.!! I was expecting the compiler to throw a flag. Why would
- > someone do this??
- >
- > My best guess is that they are making sure the TableType gets only one
- > byte instead of four (On Unix).
- > TIA
- > Srini.
-
- If the preprocessor #define statement follows the typedef as you show, it
- shadows the latter as the C preprocessor is run first against the source
- file. This causes all instances of the string "TableType" (outside of
- quotes, of course), to be converted to the string "unsigned char". This
- means that a declaration of
-
- TableType variable;
-
- is converted to
-
- unsigned char variable;
-
- before it is actually passed into the compiler.
-
- --
- Larry Kearney | "You want fries with that?"
- Applied Signal Technology |
- larry_kearney@appsig.com |
-